package com.kaishengit.util;

import java.io.UnsupportedEncodingException;

public class StringUtil {
	public static Integer StingToInteger(String str) {
		int n = 0;
		try {
			n = Integer.parseInt(str);
		} catch (NumberFormatException e) {
			n = 0;
		}
		return n;
	}

	public static Float StingToFloat(String str) {
		float n = 0f;
		if (StringIsEmpty(str)) {
			return n;
		}
		try {
			n = Float.parseFloat(str.trim());
		} catch (NumberFormatException e) {
			n = 0f;
		}
		return n;
	}

	public static boolean StringIsEmpty(String str) {
		if (null == str || "".equals(str.trim())) {
			return true;
		}
		return false;
	}

	public static String ISO8859ToUTF(String str) {
		if (StringIsEmpty(str)) {
			return "";
		}
		if (StringIsEmpty(str)) {
			return "";
		}
		try {
			return new String(str.getBytes("ISO8859-1"), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return "";
	}
}
